<?php
/**
 * Create By: PhpStorm
 * User: yihua
 * File: GetCoupon.php
 * Date: 2017/1/18
 * Time: 0:10
 */
namespace app\api\model\page\shop;

use app\library\Error;
use app\library\PageBase;
use app\api\model\dao\Coupon;

class GetCoupon extends PageBase
{
    public function __construct()
    {
        parent::__construct();
    }

    public function excute($param)
    {
        if (false === $this->checkToken($param)) {
            //return $this->getRes(Error::ERR_NO_AUTH);
        }
        $objCouponModel = new Coupon();
        $data = $objCouponModel->getCouponList();
        if (false === $data) {
            return $this->getRes(Error::ERR_SYS);
        }
        foreach ($data as $key => $value) {
            $data[$key]['start_time'] = date('Ymd H:i:s', $value['start_time']);
            $data[$key]['end_time'] = date('Ymd H:i:s', $value['end_time']);
        }

        $this->data = $data;
        return $this->getRes();
    }
}